<?php require admin_tpl('header');?>

<div class="tab">
	<ul>
		<?php if ( check_perm('blog','post') ) { ?>
		<li><a href="?mod=blog&ac=write">撰写文章</a></li>
		<?php } ?>
		<li><a href="?mod=blog&ac=list">文章列表</a></li>
		<?php if ( check_perm('blog','addcate') ||  check_perm('blog','editcate') ||  check_perm('blog','delcate')) {?>
		<li><a href="?mod=blog&ac=category" class="on">文章分类</a></li>
		<?php } ?>
		<?php if ( is_founder() ) { ?>
		<li><a href="?mod=blog&ac=blogmeta">自定义域</a></li>
		<?php }?>
	</ul>
</div>

<div class="main">

<?php if ($do == 'list') { ?>

	<form name="update" method="post" action="?mod=blog&ac=category">
		<input type="hidden" name="do" id="do" value="" />
		<table class="datalist" cellspacing="0" id="list">
			<tr>
				<th width="50" class="firstcol">选择</th>
				<th width="50">ID</th>
				<th width="150">名称</th>
				<th width="100">统计</th>
				<th width="100">排序</th>
				<th width="150">操作</th>
				<th>&nbsp;</th>
			</tr>
			<?php foreach ($result as $row) : ?>
			<tr id="row_<?php echo $row['id']; ?>" align="center">
				<td><input type="checkbox" name="id[]" value="<?php echo $row['id']; ?>" class="checkbox" <?php if ($row['id']==1) { echo 'disabled';}?>></td>
				<td><?php echo $row['id']; ?></td>
				<td align="left"><?php echo $row['catename']; ?></td>
				<td><a href="?mod=blog&cateid=<?php echo $row['id'];?>"><b style="color:red"><?php echo $row['count'];?></b></a></td>
				<td><input type="text" name="order[<?php echo $row['id'];?>]" size="5" value="<?php echo $row['orderid'];?>" /></td>
				<td>
				<?php if ( check_perm('blog','editcate') ) {  ?>
				<a href="?mod=blog&ac=category&do=edit&id=<?php echo $row['id']; ?>">编辑</a> |
				<?php } ?>
				<?php if ( check_perm('blog','delcate') ) {  ?>
				<a href="?mod=blog&ac=category&do=del&id=<?php echo $row['id'];?>" onclick="return confirm('该分类下的文章将被移动到ID为1的默认分类，如果您需要删除分类下的文章，请到文章管理进行操作。确定要删除吗？')">删除</a>
				<?php }?>
				</td>
				<td>&nbsp;</td>
			</tr>
			<?php endforeach; ?>
			<tr>
				<td align="center"><input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="check_all(this)" /></td>
				<td><label for="chkall">全选</label></td>
				<td colspan="5">将选中分类合并到
				<select name="tocid">
					<option value="0">-- 请选择 --</option>
					<?php echo cate_options('blog',0);?>
				</select>
				<input type="button" value="执行操作" class="submit" onclick="do_submit('merge', this.form)" />
				</td>
			</tr>
			<tr><td colspan="8"><input type="button" value="更新分类" class="button" onclick="do_submit('update', this.form)" />
			<?php if ( check_perm('blog','addcate') ) { ?>
			<input type="button" value="添加分类" onclick="window.location.href='?mod=blog&ac=category&do=add'" class="button" />
			<?php } ?>
			</td></tr>
		</table>
	</form>

<?php } elseif ($do == 'add' || $do == 'edit') { ?>

<form name="save" method="post" action="?mod=blog&ac=category&do=save" onsubmit="return category_save()">
<input type="hidden" name="id" value="<?php echo $cate['id'];?>" />
<table>
	<tr>
		<td align="right" width="80">名称：</td>
		<td><input type="text" name="catename" class="input" size="20" value="<?php echo $cate['catename'];?>" /></td>
	</tr>
	<tr>
		<td align="right" width="80">父级分类：</td>
		<td>
		<select name="parentid">
			<option value="0">请选择</option>
			<?php echo cate_options('blog', $cate['parentid'],1)?>
		</select>
		</td>
	</tr>
	<tr>
		<td align="right">别名：</td>
		<td><input type="text" name="alias" value="<?php echo $cate['alias'];?>" class="input" size="50" onkeyup="this.value=this.value.replace(/[^a-z0-9\-_.]/ig,'')" /><span>显示在URL上的名称，由字母、数字、下划线、减号、小数点组成。</span></td>
	</tr>
	<tr>
		<td align="right">关键字：</td>
		<td><input type="text" name="keywords" value="<?php echo $cate['keywords'];?>" class="input" size="50" /><span>设置页面meta标签的keywords，多个关键字用英文逗号","分隔</span></td>
	</tr>
	<tr>
		<td align="right">描述：</td>
		<td><textarea name="description" rows="4" cols="50"><?php echo $cate['description'];?></textarea><span>设置页面meta标签的description</span>
		</td>
	</tr>
	<tr>
		<td align="right">跳转：</td>
		<td><input type="text" name="redirect" value="<?php echo $cate['redirect'];?>" class="input" size="50" /><span>点击该分类要跳转到的地址</span></td>
	</tr>
	<tr><td></td><td><input type="submit" class="button" value="保存分类" /> <input type="button" class="button" onclick="history.back()" value="取消返回" /></td></tr>
</table>
</form>

<?php } ?>
</div>

<?php require admin_tpl('footer')?>